AC_INIT(libguile)

all_subdirs=`cat $srcdir/*/PLUGIN/REQ $srcdir/*/PLUGIN/OPT /dev/null | tsort | xargs echo`
req_subdirs=`cat $srcdir/*/PLUGIN/REQ /dev/null | tsort | xargs echo`
opt_subdirs=`cat $srcdir/*/PLUGIN/OPT /dev/null | tsort | xargs echo`
AC_CONFIG_SUBDIRS($all_subdirs)
existingdirs=
for d in $all_subdirs; do
  if test -d $srcdir/$d ; then
    existingdirs="$existingdirs $d"
    if test -f $srcdir/$d/PLUGIN/GUILE.greet ; then
      cat $srcdir/$d/PLUGIN/GUILE.greet
    elif test -f $srcdir/$d/PLUGIN/PLUGIN.greet ; then
      cat $srcdir/$d/PLUGIN/PLUGIN.greet
    else
      echo ===
      echo === Configuring plug-in component $d
      echo ===
    fi
  fi
done

for d in $req_subdirs; do
  if test ! -d $srcdir/$d ; then
    echo ===
    echo === ERROR: Missing required package: $d
    echo ===
    exit 1
  fi
done

for d in $opt_subdirs; do
  if test ! -d $srcdir/$d ; then
    echo ===
    echo === WARNING: Missing suggested package: $d
    echo ===
  fi
done

AC_SUBST(existingdirs)
AC_OUTPUT(Makefile)
